package demo.practice.leetcode_msjd;

import java.util.Stack;

public class Msjd0304 {
}


class MyQueue {


    Stack<Integer> spush;
    Stack<Integer> spop;

    /**
     * Initialize your data structure here.
     */
    public MyQueue() {
        spush = new Stack<>();
        spop = new Stack<>();
    }

    /**
     * Push element x to the back of queue.
     */
    public void push(int x) {
        spush.push(x);
    }

    /**
     * Removes the element from in front of queue and returns that element.
     */
    public int pop() {
        peek();
        return spop.pop();

    }

    /**
     * Get the front element.
     */
    public int peek() {
        if (spop.empty() && spush.empty())
            throw new RuntimeException("none elements");

        if (spop.empty()) {
            while (!spush.empty())
                spop.push(spush.pop());
        }
        return spop.peek();
    }

    /**
     * Returns whether the queue is empty.
     */
    public boolean empty() {
        return spop.empty() && spush.empty();
    }
}